home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 90 / CDMM_90_1.ISO / Cycling Manager 2 / CyclingManager2Demo.exe / Disk1 / data1.cab / Game / DataCM2 / scripts / elements / select.cnh < prev    next >
Encoding:
Text File  |  2002-05-10  |  19.3 KB  |  782 lines

  1. // Standard select
  2. // forward declaration
  3. func Gui_Component NewSelect(Menu_Material _pFont, i32x _iX, i32x _iY, i32x _iSourceId,i32x _iReturnId);
  4. func Gui_Component NewSelectExt(Menu_Material _pFont, i32x _iX, i32x _iY, i32x _iSourceId,i32x _iReturnId,i32x _iSort,i32x _iShowList,i32x _iEditbox,i32x _iAlignX,i32x _iAlignY, f32x _fFontSize);
  5. func Gui_Component NewGroupOption(i32x _iWidth);
  6. func Gui_Component NewGroupOptionExt(i32x _iWidth,i32x _iOffsetX,i32x _iOffsetY);
  7.  
  8. //Receiving messages
  9. message ShowSelectList();
  10. message HideSelectList();
  11. message SelectPrevious();
  12. message SelectNext();
  13.  
  14. message AddOption(Gui_Component _gcOption);
  15. message SelectOption(i32x _iValue);
  16. message SelectNone    (szx _szTxt);    // select none of the objects, puts szTxt
  17.  
  18. //Sending messages
  19. message QuietSelectIndex(Gui_Component _pSender,i32x _iIndex);
  20. message SelectIndex(Gui_Component _pSender,i32x _iIndex);
  21. message SelectInt(Gui_Component _pSender,i32x _iValue);
  22. message SelectFloat(Gui_Component _pSender,f32x _fValue);
  23. message SelectString(Gui_Component _pSender,szx _szValue);
  24.  
  25. // Data class
  26. class Gui_dtSelect
  27. {
  28.     var Gui_Component    gcEditBox;      // edit box
  29.     var Gui_Component    gcCaption;      // caption
  30.     var Gui_Component    gcButtonClose;      // button list close
  31.     var Gui_Component    gcButtonOpen;      // button list open
  32.     var Gui_Component    gcList;          // list
  33.     var boolx            bListHidden;  // if list is visible => true; else => false 
  34.     var i32x            iHeight;
  35.     var i32x            iSourceId;
  36.     var i32x            iReturnId;
  37.     var boolx            bSort;
  38.     var boolx            bQuiet;
  39.     var i32x            iRowSelected;      // contain the row which is selected
  40.     var i32x iShowList;
  41.     var i32x iEditbox;
  42. };
  43. class Gui_dtGroupOption
  44. {
  45.     var i32x iWidth; // GroupOption width
  46.     var i32x iLastPosX; // Last item posX
  47.     var i32x iLastPosY; // Last item posY
  48.     var i32x iMaxY; // Last row max pos y
  49.     var i32x iOffsetX; // offset X
  50.     var i32x iOffsetY; // offset Y
  51. };
  52.  
  53. // Predeclaration
  54. // event edit box
  55. /*
  56. func i32x Select_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
  57. func void Select_OnKeyDown(i32x _iKey, i32x _iCount);
  58. func void Select_OnChar(szx _szChar,i32x _iCount);
  59. func i32x Select_OnGainFocus();
  60. func i32x Select_OnKeyUp(i32x _iKey);
  61. func i32x Select_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
  62. func i32x Select_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton);
  63. func i32x Select_OnMouseMove(i32x _iX,i32x _iY);
  64. func i32x Select_OnMouseDblClick(i32x _iX,i32x _iY,i32x _iButton);
  65. */
  66.  
  67. func void Select_OnClick(Gui_Component _poComponent);
  68. func void Select_OnCellSelect(i32x _iRow);
  69. func void Select_ShowList();
  70. func void Select_HideList();
  71. func i32x Select_OnGainFocus();
  72. func i32x Select_OnLoseFocus();
  73.  
  74. func i32x Select_OnSelectPrevious();
  75. func i32x Select_OnSelectNext();
  76. func i32x Select_OnQuietSelectIndex(Gui_Component _pSender,i32x _iIndex);
  77.  
  78. func i32x Select_OnSelectNone    (szx _szTxt);
  79. // Message handling interface
  80. interface Gui_iSelect
  81. {
  82.     // Gui System Messages
  83. /*    Select_OnMouseMove        MouseMove;
  84.     Select_OnMouseDown        MouseDown;
  85.     Select_OnMouseUp        MouseUp;
  86.     Select_OnMouseClick        MouseClick;
  87.     Select_OnMouseDblClick    MouseDblClick;
  88.     Select_OnKeyDown        KeyDown;
  89.     Select_OnChar            Char;
  90.     Select_OnKeyUp            KeyUp;*/
  91. //    Select_OnGainFocus        GainFocus;
  92.     Select_OnLoseFocus        LoseFocus;
  93.     Select_OnClick            Click;
  94.     Select_OnCellSelect        CellSelect;
  95.     Select_ShowList            ShowSelectList;
  96.     Select_HideList            HideSelectList;
  97.     Select_OnSelectPrevious SelectPrevious;
  98.     Select_OnSelectNext SelectNext;
  99.     Select_OnQuietSelectIndex QuietSelectIndex;
  100.     Select_OnSelectNone            SelectNone;
  101. }
  102.  
  103. func void Group_AddOption(Gui_Component _gcOption);
  104. func void Group_SelectOption(i32x _iValue);
  105. func void Group_OnRadioCheck(Gui_Component _pComponent,i32x _iValue);
  106.  
  107. interface Gui_iGroupOption
  108. {
  109.     Group_AddOption AddOption;
  110.     Group_SelectOption SelectOption;
  111.     Group_OnRadioCheck RadioCheck;
  112. }
  113.  
  114. /*
  115.  *    Function        : Group option constructor with cursor
  116.  *    Parameters        : _iX : maximum width
  117.  */
  118. func Gui_Component NewGroupOption(i32x _iWidth)
  119. {
  120.     var Gui_Component gcGroup;
  121.     var i32x iOffsetX,iOffsetY;
  122.     iOffsetX = 0;
  123.     iOffsetY = 0;
  124.     gcGroup = NewGroupOptionExt(_iWidth,iOffsetX,iOffsetY);
  125.     return gcGroup;
  126. }
  127. func Gui_Component NewGroupOptionExt(i32x _iWidth,i32x _iOffsetX,i32x _iOffsetY)
  128. {
  129.     var Gui_Component composite;
  130.     var Gui_dtGroupOption pdtData;
  131.  
  132.     // Create an object that will contain Bitmap buton + caption
  133.     composite = NewObject(Gui_iGroupOption);
  134.     // Affect data pointer
  135.     pdtData = new Gui_dtGroupOption;
  136.     SetData(composite,pdtData);
  137.  
  138.     // members init
  139.     pdtData.iLastPosX = 0;
  140.     pdtData.iLastPosY = 0;
  141.     pdtData.iOffsetX = _iOffsetX;
  142.     pdtData.iOffsetY = _iOffsetY;
  143.     pdtData.iMaxY = 0;
  144.  
  145.     // Stretch composite to width
  146.     pdtData.iWidth = _iWidth;
  147.     StretchTo(composite,_iWidth,0);
  148.  
  149.     // Make group option transparent
  150.     Transparent(composite);
  151.  
  152.     return composite;
  153. }
  154.  
  155. func void Group_AddOption(Gui_Component _gcOption)
  156. {
  157.     var Gui_Component pthis,pparent;
  158.     var Gui_dtGroupOption pdtData;
  159.     var i32x id;
  160.     var i32x px,py;
  161.  
  162.     // Retrieve group option pointer
  163.     pthis = GetThis();
  164.  
  165.     // Retrieve data pointer
  166.     pdtData = GetData(pthis);
  167.  
  168.     // Mount option inside group option
  169.     id = MountComponent(pthis,_gcOption);
  170.  
  171.     // Calc option position
  172.     px = pdtData.iLastPosX;
  173.     py = pdtData.iLastPosY;
  174.  
  175.     // Next line ?
  176.     if(px+SizeX(_gcOption)>pdtData.iWidth)
  177.     {
  178.         px = 0;
  179.         py = pdtData.iMaxY + pdtData.iOffsetY;
  180.     }
  181.     // update Max y pos
  182.     if(py + SizeY(_gcOption)>pdtData.iMaxY)
  183.     {
  184.         pdtData.iMaxY = py + SizeY(_gcOption);
  185.     }
  186.  
  187.     // Move option to calculated pos
  188.     MoveTo(_gcOption,px,py);
  189.  
  190.     pdtData.iLastPosX = px + SizeX(_gcOption) + pdtData.iOffsetX;
  191.     pdtData.iLastPosY = py;
  192.  
  193.     // Stretch group option to fit height
  194.     StretchTo(pthis,pdtData.iWidth,pdtData.iMaxY);
  195.  
  196.     // Send window content update
  197.     pparent = GetParent(pthis);    
  198.     if(pparent)
  199.         pparent<<WindowUpdate();
  200. }
  201. func void Group_SelectOption(i32x _iValue)
  202. {
  203.     var Gui_Component pthis,pchild;
  204.     var Gui_dtGroupOption pdtData;
  205.     var i32x iNumComponents,i;
  206.  
  207.     // Retrieve group option pointer
  208.     pthis = GetThis();
  209.  
  210.     // Retrieve data pointer
  211.     pdtData = GetData(pthis);
  212.  
  213.     // Send update to each radio button
  214.     iNumComponents = GetComponentNumber(pthis);
  215.     i=0;
  216.     while(i<iNumComponents)
  217.     {
  218.         pchild = GetComponent(pthis,i);
  219.         if(pchild)
  220.         {
  221.             pchild<<QuietRadioCheck(_iValue);
  222.         }
  223.         i=i+1;
  224.     }
  225. }
  226. func void Group_OnRadioCheck(Gui_Component _pComponent,i32x _iValue)
  227. {
  228.     var Gui_Component pthis,pchild,parent;
  229.     var Gui_dtGroupOption pdtData;
  230.     var i32x iNumComponents,i;
  231.  
  232.     // Retrieve group option pointer
  233.     pthis = GetThis();
  234.  
  235.     // Retrieve data pointer
  236.     pdtData = GetData(pthis);
  237.  
  238.     // Send update to each radio button
  239.     iNumComponents = GetComponentNumber(pthis);
  240.     i=0;
  241.     while(i<iNumComponents)
  242.     {
  243.         pchild = GetComponent(pthis,i);
  244.         if(pchild)
  245.         {
  246.             if(pchild != _pComponent)
  247.             {
  248.                 pchild<<QuietRadioCheck(_iValue);
  249.             }
  250.         }
  251.         i=i+1;
  252.     }
  253.     parent = GetParent(pthis);
  254.     if(parent)    parent<<RadioCheck(pthis,_iValue);
  255. }
  256.  
  257.  
  258. /*
  259.  *    Function        : Select constructor with cursor
  260.  *    Parameters        : _pMaterial material pointer, _iX : width, _iY : height
  261.  */
  262. func Gui_Component NewSelect(Menu_Material _pFont, i32x _iX, i32x _iY, i32x _iSourceId,i32x _iReturnId)
  263. {
  264.     var i32x bSort;
  265.     var i32x bShowList;
  266.     var i32x bEditBox;
  267.     var i32x eHAlign;
  268.     var i32x eVAlign;
  269.     var f32x fFontSize = 1.0;
  270.  
  271.     bSort = 0;
  272.     bShowList = 1;
  273.     bEditBox = 1;
  274.     eHAlign = e_GUI_HAlign_Left;
  275.     eVAlign = e_GUI_VAlign_Top;
  276.  
  277.     return NewSelectExt(_pFont,_iX,_iY,_iSourceId,_iReturnId,bSort,bShowList,bEditBox,eHAlign,eVAlign,fFontSize);
  278. }
  279. func Gui_Component NewSelectExt(Menu_Material _pFont, i32x _iX, i32x _iY, i32x _iSourceId,i32x _iReturnId,i32x _iSort,i32x _iShowList,i32x _iEditbox,i32x _iAlignX,i32x _iAlignY, f32x _fFontSize)
  280. {
  281.     var Gui_Component composite;
  282.     var Gui_dtSelect pdtSelect;
  283.     var i32x sy_button, sx, sy_editbox;
  284.     var f32x sy_move;
  285.     var szx szValue;
  286.  
  287.     // Create an object that will contain Bitmap buton + caption
  288.     composite = NewObject(Gui_iSelect);
  289.     // Affect data pointer
  290.     pdtSelect = new Gui_dtSelect;
  291.     SetData(composite,pdtSelect);
  292.  
  293.     // Four component in composite select
  294.     SetComponentNumber(composite,4);
  295.  
  296.     pdtSelect.bQuiet = false;
  297.  
  298.     //Editbox obtion
  299.     pdtSelect.iEditbox=_iEditbox;
  300.  
  301.     //Showlist option
  302.     pdtSelect.iShowList=_iShowList;
  303.     
  304.     // Create Button
  305.     if(pdtSelect.iShowList)
  306.     {
  307.         // button list close
  308.         pdtSelect.gcButtonClose = NewButtonDyn(smBtnListClose);
  309.         sx = SizeX(pdtSelect.gcButtonClose);
  310.         sy_button = SizeY(pdtSelect.gcButtonClose);
  311.         StretchTo(pdtSelect.gcButtonClose,sx,sy_button);
  312.         MountComponent(composite,pdtSelect.gcButtonClose);
  313.         MoveTo(pdtSelect.gcButtonClose,_iX,0);
  314.         SetAlign(pdtSelect.gcButtonClose,e_GUI_HAlign_Zoom,e_GUI_HAlign_Zoom);
  315.  
  316.         // button list open
  317.         pdtSelect.gcButtonOpen = NewButtonDyn(smBtnListOpen);
  318.         StretchTo(pdtSelect.gcButtonOpen,sx,sy_button);
  319.         MountComponent(composite,pdtSelect.gcButtonOpen);
  320.         MoveTo(pdtSelect.gcButtonOpen,_iX,0);
  321.         pdtSelect.gcButtonOpen<<Hide();
  322.         SetAlign(pdtSelect.gcButtonOpen,e_GUI_HAlign_Zoom,e_GUI_HAlign_Zoom);
  323.     }
  324.     else
  325.     {    
  326.         sx=0;
  327.     }
  328.  
  329.     // Create EditBox
  330.     if(pdtSelect.iEditbox)
  331.     {
  332.         pdtSelect.gcEditBox = NewEditBoxExt(_pFont,cEBColor,_fFontSize);
  333.         sy_editbox = SizeY(pdtSelect.gcEditBox);
  334.         pdtSelect.gcEditBox<<EbCResize(_iX,sy_editbox);
  335.         pdtSelect.gcEditBox<<EbCAlign(_iAlignX,_iAlignY);
  336.         pdtSelect.gcEditBox<<Disable();
  337.         MountComponent(composite,pdtSelect.gcEditBox);
  338.         sy_move = (sy_button - sy_editbox) / 2;
  339.         MoveTo(pdtSelect.gcEditBox,0,sy_move);
  340.     }
  341.     else
  342.     {
  343.         pdtSelect.gcCaption = NewCaption(_pFont,"");
  344.         sy_editbox = SizeY(pdtSelect.gcCaption);
  345.         SetAlign(pdtSelect.gcCaption,_iAlignX,_iAlignY);
  346.         StretchTo(pdtSelect.gcCaption,_iX,sy_editbox);
  347.         pdtSelect.gcCaption<<Disable();
  348.         MountComponent(composite,pdtSelect.gcCaption);
  349.         sy_move = (sy_button - sy_editbox) / 2;
  350.         MoveTo(pdtSelect.gcCaption,0,sy_move);
  351.     }    
  352.  
  353.     // Init boolean
  354.     pdtSelect.bListHidden = true;
  355.     pdtSelect.bSort = _iSort;
  356.  
  357.     // init row
  358.     pdtSelect.iRowSelected = 0;
  359.     
  360.     // Save SourceId
  361.     pdtSelect.iSourceId = _iSourceId;
  362.     pdtSelect.iReturnId = _iReturnId;
  363.  
  364.     // Init Edit Box
  365.     if(Join_GetNumRows(pdtSelect.iSourceId)>0)
  366.     {
  367.         if(pdtSelect.bSort)
  368.         {
  369.             if(Join_GetDataType(pdtSelect.iSourceId)==STRING_DATA)
  370.             szValue = Join_GetStringFromSortedIndex(pdtSelect.iSourceId,pdtSelect.iRowSelected);
  371.             else if(Join_GetDataType(pdtSelect.iSourceId)==INT_DATA)
  372.                 //use localized string
  373.             szValue = Join_GetStringFromKey(g_oLocalJoins.m_iLocalizedString,Join_GetIntFromSortedIndex(pdtSelect.iSourceId,pdtSelect.iRowSelected));
  374.             else println("Error SourceID is not string or localized string");
  375.         }
  376.         else
  377.         {
  378.             if(Join_GetDataType(pdtSelect.iSourceId)==STRING_DATA)
  379.             szValue = Join_GetStringFromIndex(pdtSelect.iSourceId,pdtSelect.iRowSelected);
  380.             else if(Join_GetDataType(pdtSelect.iSourceId)==INT_DATA)
  381.                 //use localized string
  382.             szValue = Join_GetStringFromKey(g_oLocalJoins.m_iLocalizedString,Join_GetIntFromIndex(pdtSelect.iSourceId,pdtSelect.iRowSelected));
  383.             else println("Error SourceID is not string or localized string");
  384.         }
  385.     }
  386.     else
  387.         szValue = "None";
  388.  
  389.     if(pdtSelect.iEditbox)
  390.         pdtSelect.gcEditBox<<EbCText(szValue);
  391.     else
  392.     {
  393.         pdtSelect.gcCaption<<Caption(szValue);
  394.     }
  395.     
  396.     // Save Height
  397.     pdtSelect.iHeight = _iY;
  398.  
  399.     // Stretch
  400.     StretchTo(composite,_iX+sx,sy_button);
  401.     
  402.     return composite;
  403. }
  404.  
  405. /*
  406.  *    Function        : On Click Select
  407.  */
  408. func void Select_OnClick(Gui_Component _poComponent) 
  409. {
  410.     var Gui_Component pthis;
  411.     var Gui_dtSelect pdtSelect;
  412.  
  413.     // Get This
  414.     pthis = GetThis();
  415.     // Get Data
  416.     pdtSelect = GetData(pthis);
  417.  
  418.     // Show or Hide Select List
  419.     if (pdtSelect.bListHidden == true) 
  420.     {
  421.         pthis<<ShowSelectList();
  422.     }
  423.     else 
  424.     {
  425.         pthis<<HideSelectList();
  426.     }
  427. }
  428.  
  429. /*
  430.  *    Function        : Show Select List
  431.  */
  432. func void Select_ShowList()
  433. {
  434.     var Gui_Component pthis;
  435.     var Gui_Component pparent;
  436.     var Gui_Component gcListTable;
  437.     var Gui_Component gcListColumn;
  438.     var Gui_Component gcListCell;
  439.     var Gui_dtSelect pdtSelect;
  440.     var i32x iX, iY, iSxEditBox, iSyEditBox, iSxButton,i, iNumRows,iSyButton;
  441.  
  442.  
  443.     // Get This
  444.     pthis = GetThis();
  445.     // Get Data
  446.     pdtSelect = GetData(pthis);
  447.     
  448.     if(pdtSelect.iEditbox)
  449.     {
  450.         iSyEditBox = SizeY(pdtSelect.gcEditBox);
  451.         iSxEditBox = SizeX(pdtSelect.gcEditBox);
  452.     }
  453.     else
  454.     {
  455.         iSyEditBox = SizeY(pdtSelect.gcCaption);
  456.         iSxEditBox = SizeX(pdtSelect.gcCaption);
  457.     }
  458.      
  459.     if(pdtSelect.iShowList)
  460.     {
  461.         iSxButton  = SizeX(pdtSelect.gcButtonClose);
  462.         iSyButton = SizeY(pdtSelect.gcButtonClose);
  463.  
  464.         // Change button
  465.         pdtSelect.gcButtonOpen<<Show();
  466.         pdtSelect.gcButtonClose<<Hide();
  467.     }
  468.     else
  469.     {
  470.         iSxButton  = 0;
  471.         iSyButton = 0;
  472.     }
  473.     if(iSyButton<iSyEditBox)
  474.         iSyButton= iSyEditBox;
  475.  
  476.  
  477.     // Create List
  478.     if (pdtSelect.gcList)
  479.     {
  480.         DeleteComponent(pdtSelect.gcList);
  481.         pdtSelect.gcList = NULL;
  482.     }
  483.     pdtSelect.gcList = NewWindow(iSxEditBox+iSxButton,pdtSelect.iHeight);
  484.  
  485.     // Init
  486.     i = 0;
  487.     gcListTable = NewTable();
  488.     gcListColumn = NewColumn(iSxEditBox);
  489.     iNumRows = Join_GetNumRows(pdtSelect.iSourceId);
  490.     while (i < iNumRows) {
  491.         gcListCell = NewTextCell(pdtSelect.iSourceId);
  492.         gcListCell<<CellUpdate(i);
  493.         gcListColumn<<AddCell(gcListCell);
  494.         i = i + 1;
  495.     }
  496.  
  497.     // Mount
  498.     gcListTable<<AddColumn(gcListColumn);
  499.     pdtSelect.gcList<<WindowMount(gcListTable);
  500.     MountComponent(pthis,pdtSelect.gcList);
  501.  
  502.     // Give Focus
  503.     GiveFocus(pdtSelect.gcList);
  504.  
  505.     // Move
  506.     MoveTo(pdtSelect.gcList,0,iSyButton);
  507.  
  508.     pdtSelect.bListHidden = false;
  509.     
  510.     // calcul new size of select
  511.     iX = iSxEditBox + iSxButton;
  512.     iY = iSyEditBox + pdtSelect.iHeight;
  513.  
  514.     // Stretch
  515.     StretchTo(pthis,iX,iY);
  516.  
  517.     pparent = GetParent(pthis);
  518.     if(pparent)
  519.         pparent<<WindowUpdate();
  520. }
  521.  
  522. /*
  523.  *    Function        : Hide Select List
  524.  */
  525. func void Select_HideList()
  526. {
  527.     var Gui_Component pthis,pparent;
  528.     var Gui_dtSelect pdtSelect;
  529.     var i32x iX, iY,iSxButton,iSxEditBox,iSyEditBox;
  530.  
  531.  
  532.     // Get This
  533.     pthis = GetThis();
  534.     // Get Data
  535.     pdtSelect = GetData(pthis);
  536.  
  537.     if (pdtSelect.gcList)
  538.     {
  539.         pdtSelect.gcList<<Hide();
  540.     }
  541.  
  542.     pdtSelect.bListHidden = true;
  543.  
  544.     if(pdtSelect.iShowList)
  545.     {
  546.         iSxButton  = SizeX(pdtSelect.gcButtonClose);
  547.         pdtSelect.gcButtonOpen<<Hide();
  548.         pdtSelect.gcButtonClose<<Show();
  549.     }
  550.     else
  551.     {
  552.         iSxButton  = 0;
  553.     }
  554.  
  555.     if(pdtSelect.iEditbox)
  556.     {
  557.         iSyEditBox = SizeY(pdtSelect.gcEditBox);
  558.         iSxEditBox = SizeX(pdtSelect.gcEditBox);
  559.     }
  560.     else
  561.     {
  562.         iSyEditBox = SizeY(pdtSelect.gcCaption);
  563.         iSxEditBox = SizeX(pdtSelect.gcCaption);
  564.     }
  565.  
  566.     // Calculate new size
  567.     iX = iSxEditBox + iSxButton;
  568.     iY = iSyEditBox;
  569.  
  570.     StretchTo(pthis,iX,iY);
  571.     pparent = GetParent(pthis);
  572.     if(pparent)
  573.         pparent<<WindowUpdate();
  574. }
  575.  
  576. /*
  577.  *    Function        : On Cell Select Click
  578.  */
  579. func void Select_OnCellSelect(i32x _iRow)
  580. {
  581.     var Gui_Component pthis, parent;
  582.     var Gui_dtSelect pdtSelect;
  583.     var szx szValue;
  584.     var f32x fValue;
  585.     var i32x iValue;
  586.  
  587.     // Get This
  588.     pthis = GetThis();
  589.     parent = GetParent(pthis);
  590.     // Get Data
  591.     pdtSelect = GetData(pthis);
  592.  
  593.     // Retrieve text
  594.     if(pdtSelect.bSort)
  595.     {
  596.         if(Join_GetDataType(pdtSelect.iSourceId)==STRING_DATA)
  597.         szValue = Join_GetStringFromSortedIndex(pdtSelect.iSourceId,_iRow);
  598.         else if(Join_GetDataType(pdtSelect.iSourceId)==INT_DATA)
  599.             //use localized string
  600.         szValue = Join_GetStringFromKey(g_oLocalJoins.m_iLocalizedString,Join_GetIntFromSortedIndex(pdtSelect.iSourceId,_iRow));
  601.         else println("Error SourceID is not string or localized string");
  602.     }
  603.     else
  604.     {
  605.         if(Join_GetDataType(pdtSelect.iSourceId)==STRING_DATA)
  606.         szValue = Join_GetStringFromIndex(pdtSelect.iSourceId,_iRow);
  607.         else if(Join_GetDataType(pdtSelect.iSourceId)==INT_DATA)
  608.             //use localized string
  609.         szValue = Join_GetStringFromKey(g_oLocalJoins.m_iLocalizedString,Join_GetIntFromIndex(pdtSelect.iSourceId,_iRow));
  610.         else println("Error SourceID is not string or localized string");
  611.     }
  612.  
  613.     if(pdtSelect.iEditbox)
  614.     {
  615.         pdtSelect.gcEditBox<<EbCText(szValue);
  616.     }
  617.     else
  618.     {
  619.         println("pdtSelect.gcCaption<<Caption");
  620.         println(szValue);
  621.  
  622.         pdtSelect.gcCaption<<Caption(szValue);    
  623.     }
  624.  
  625.  
  626.     // Hide Select List
  627.     if (pdtSelect.bListHidden == false) pthis<<HideSelectList();
  628.  
  629.     // cellselect => parent if change
  630.     if(!pdtSelect.bQuiet)
  631.     {
  632.         if(pdtSelect.iReturnId==0)
  633.         {
  634.             parent<<SelectIndex(pthis,_iRow);
  635.         }
  636.         else
  637.         {
  638.             if(Join_GetDataType(pdtSelect.iReturnId)==INT_DATA)
  639.             {
  640.                 if(pdtSelect.bSort)
  641.                     iValue = Join_GetIntFromSortedIndex(pdtSelect.iReturnId,_iRow);
  642.                 else
  643.                     iValue = Join_GetIntFromIndex(pdtSelect.iReturnId,_iRow);
  644.                 parent<<SelectInt(pthis,iValue);
  645.             }
  646.             else if(Join_GetDataType(pdtSelect.iReturnId)==FLOAT_DATA)
  647.             {
  648.                 if(pdtSelect.bSort)
  649.                     fValue = Join_GetFloatFromSortedIndex(pdtSelect.iReturnId,_iRow);
  650.                 else
  651.                     fValue = Join_GetFloatFromIndex(pdtSelect.iReturnId,_iRow);
  652.                 parent<<SelectFloat(pthis,fValue);
  653.             }
  654.             else if(Join_GetDataType(pdtSelect.iReturnId)==STRING_DATA)
  655.             {
  656.                 if(pdtSelect.bSort)
  657.                     szValue = Join_GetStringFromSortedIndex(pdtSelect.iReturnId,_iRow);
  658.                 else
  659.                     szValue = Join_GetStringFromIndex(pdtSelect.iReturnId,_iRow);
  660.                 parent<<SelectString(pthis,szValue);
  661.             }
  662.             else
  663.             {
  664.                 print("Error : unknown type for CellSelect:");
  665.                 print(itoa(Join_GetDataType(pdtSelect.iReturnId)));
  666.                 print(".Return join ID is:");
  667.                 println(itoa(pdtSelect.iReturnId));
  668.             }
  669.         }
  670.     }
  671.     pdtSelect.iRowSelected = _iRow;
  672. }
  673. /*
  674. func i32x Select_OnGainFocus()
  675. {
  676.     var Gui_Component pthis;
  677.     var Gui_dtSelect pdtSelect;
  678.  
  679.     // Get This
  680.     pthis = GetThis();
  681.     // Get Data
  682.     pdtSelect = GetData(pthis);
  683.  
  684.     // Show open button
  685.     pdtSelect.gcButtonOpen<<Show();
  686. }
  687. */
  688. func i32x Select_OnLoseFocus()
  689. {
  690.     var Gui_Component pthis;
  691.     var Gui_dtSelect pdtSelect;
  692.  
  693.     // Get This
  694.     pthis = GetThis();
  695.     // Get Data
  696.     pdtSelect = GetData(pthis);
  697.  
  698.     // Hide Select List
  699.     if (pdtSelect.bListHidden == false) pthis<<HideSelectList();
  700.     // Hide two button button
  701. //    pdtSelect.gcButtonOpen<<Hide();
  702. //    pdtSelect.gcButtonClose<<Hide();
  703. }
  704.  
  705. func i32x Select_OnSelectPrevious()
  706. {
  707.     var Gui_Component pthis;
  708.     var Gui_dtSelect pdtSelect;
  709.     var i32x iNewSelectedRow;
  710.     
  711.     // Get This
  712.     pthis = GetThis();
  713.     // Get Data
  714.     pdtSelect = GetData(pthis);
  715.  
  716.     if(pdtSelect.iRowSelected>0)
  717.     {
  718.         iNewSelectedRow=pdtSelect.iRowSelected-1;
  719.         Select_OnCellSelect(iNewSelectedRow);
  720.     }
  721. }
  722.  
  723. func i32x Select_OnSelectNext()
  724. {
  725.     var Gui_Component pthis;
  726.     var Gui_dtSelect pdtSelect;
  727.     var i32x iNewSelectedRow;
  728.     
  729.     // Get This
  730.     pthis = GetThis();
  731.     // Get Data
  732.     pdtSelect = GetData(pthis);
  733.  
  734.     if(pdtSelect.iRowSelected<Join_GetNumRows(pdtSelect.iSourceId)-1)
  735.     {
  736.         iNewSelectedRow=pdtSelect.iRowSelected+1;
  737.         Select_OnCellSelect(iNewSelectedRow);
  738.     }
  739. }
  740.  
  741. func i32x Select_OnQuietSelectIndex(Gui_Component _pSender,i32x _iIndex)
  742. {
  743.     var Gui_Component pthis;
  744.     var Gui_dtSelect pdtSelect;
  745.     var i32x iNewSelectedRow;
  746.     
  747.     // Get This
  748.     pthis = GetThis();
  749.     // Get Data
  750.     pdtSelect = GetData(pthis);
  751.  
  752.     if(_iIndex>=0&&_iIndex<Join_GetNumRows(pdtSelect.iSourceId))
  753.     {
  754.         pdtSelect.bQuiet = true;
  755.         Select_OnCellSelect(_iIndex);
  756.         pdtSelect.bQuiet = false;
  757.     }
  758. }
  759.  
  760.  
  761. func i32x Select_OnSelectNone    (szx _szTxt)
  762. {
  763.     var Gui_Component pthis;
  764.     var Gui_dtSelect pdtSelect;
  765.  
  766.     // Get This
  767.     pthis = GetThis();
  768.     // Get Data
  769.     pdtSelect = GetData(pthis);
  770.  
  771.     pdtSelect.iRowSelected = -1;
  772.  
  773.     if(pdtSelect.iEditbox)
  774.     {
  775.         pdtSelect.gcEditBox<<EbCText(_szTxt);
  776.     }
  777.     else
  778.     {
  779.         pdtSelect.gcCaption<<Caption(_szTxt);    
  780.     }
  781. }
  782.